Game Variables
"Game Variables", also referred to as "Registers", store both important game information
and user-managed information that should be available to scripts. There are two different types:
Game Registers - Registers built-in to the program, listed in this documentation
User Registers - Registers defined by the user by creating extra Register space
with the appropriate option in the Game Def file
There are two different ways in which these Registers are referenced by script:
Reference By ID
When the description of a Script Command explicitly asks for a Register ID as a Parameter, Game Registers may be referenced by entering
their given ID (as in "3" for Game Register 3, "act"), and User Registers may be referenced
by prefixing the ID value with a "U" (as in "U2" for User Register 2).
Reference By Value
When the description of a Script Command asks for a "Constant Value" (an explicit number value, not a variable) as a Parameter,
the value of a Register may sometimes be substituted for this value, if the description for the Script Command explicitly
states so. When this option is available, entering a Game Register ID that is prefixed by a lower-case "r" (as in "r4" for
Game Register 4, "zone") will instruct the Command to take the current value of that Game Register as the parameter. Entering
a User Register ID that is prefixed by a capital "R" (as in "R6" for User Register 6) will instruct the Command to take the
current value of that User Register as the parameter. If the value entered for the parameter is not prefixed with "r" or "R",
it will be taken as an explicit value (the value "255" will simply mean "255").
Index:
0 - _Screen_Mode
1 - _Curr_Screen
2 - _FreezeObjects
3 - _act
4 - _zone
5 - _lastact
6 - _lastzone
7 - _InLevel
8 - _Host_Platform
9 - _Curr_Player
10 - _XMEffectParam
11 - _Tiles_Length_X
12 - _Tiles_Length_Y
13 - _Screen_Active_Width
14 - _Screen_Active_Height
15 - _Screen_Actual_Width
16 - _Screen_Actual_Height
17 - _mainvpx
18 - _mainvpy
19 - _vpxr[0]
20 - _vpxr[1]
21 - _vpyr[0]
22 - _vpyr[1]
23 - _LevelBound_X1[0]
24 - _LevelBound_X1[1]
25 - _LevelBound_Y1[0]
26 - _LevelBound_Y1[1]
27 - _LevelBound_X2[0]
28 - _LevelBound_X2[1]
29 - _LevelBound_Y2[0]
30 - _LevelBound_Y2[1]
31 - _Target_LevelBound_X1[0]
32 - _Target_LevelBound_X1[1]
33 - _Target_LevelBound_Y1[0]
34 - _Target_LevelBound_Y1[1]
35 - _Target_LevelBound_X2[0]
36 - _Target_LevelBound_X2[1]
37 - _Target_LevelBound_Y2[0]
38 - _Target_LevelBound_Y2[1]
39 - _XLoop_Active[0]
40 - _XLoop_Active[1]
41 - _YLoop_Active[0]
42 - _YLoop_Active[1]
43 - _BGOffsetX[0]
44 - _BGOffsetX[1]
45 - _BGOffsetY[0]
46 - _BGOffsetY[1]
47 - _XLoop_Size[0]
48 - _XLoop_Size[1]
49 - _YLoop_Size[0]
50 - _YLoop_Size[1]
51 - _Curr_Palette
.... - (Unused)
54 - _Water_Level
55 - _FrameCounter
56 - _VPX_Bounce[0]
57 - _VPX_Bounce[1]
58 - _VPY_Bounce[0]
59 - _VPY_Bounce[1]
.... - (Unused)
.... - (Reserved, 200-231)
.... - (Unused)
241 - _OE_Property[0]
242 - _OE_Property[1]
243 - _OE_Property[2]
244 - _OE_Property[3]
245 - _Key_InitialDelay
246 - _Key_RepeatDelay
247 - _VSync
248 - _GameFlags
249 - _FrameSkipCount
250 - _FrameSkip
251 - _FrameLock
252 - _piccount
253 - _GamePaused
254 - _Max_Objects_Used
255 - (Reserved)
Descriptions:
0 - _Screen_Mode
The current "Screen Mode". This value is for reference only; changing it manually
will cause undesirable effects. The _Set_ScreenMode
Script Command can be used to change the Screen Mode, and will automatically update this variable. Possible values are:
0 | - | _Screen_Single | - | Normal mode (default) |
2 | - | _Screen_Split | - | Split-Screen Mode |
1 - _Curr_Screen
The screen that is currently being manipulated. This value is managed by HCGE as screens are being drawn, and is most
useful during Drawing Functions. It is for reference only; changing
it manually could cause undesirable effects. Possible values are:
0 | - | _Player1 | - | Player 1; top/single screen |
1 | - | _Player2 | - | Player 2; bottom screen |
2 - _FreezeObjects
Contains Flags for freezing various gameplay elements (0 for active, 1 for frozen):
0 | - | _Freeze_PalAni | - | Palette Rotation/Animation |
1 | - | _Freeze_TileAni | - | Tile Animation |
2 | - | | - | Reserved |
3 | - | _Freeze_Objects | - | All Objects |
... | - | | - | Unused |
28 | - | _OF_FreezeFlag_3 | - | Objects with Object_Flags Flag 28 set |
29 | - | _OF_FreezeFlag_2 | - | Objects with Object_Flags Flag 29 set |
30 | - | _OF_FreezeFlag_1 | - | Objects with Object_Flags Flag 30 set |
31 | - | _OF_FreezeFlag_0 | - | Objects with Object_Flags Flag 31 set |
3 - _act
4 - _zone
These are the IDs of the current "Act" and "Zone". Changing them
manually will have no immediate effect unless one is scripted. The InLevel variable must
be set to 0 for HCGE to load the given Act/Zone. This can be managed all at once by use of the _SetLevel Script Command
5 - _lastact
6 - _lastzone
7 - _InLevel
This value signifies whether the game state is "level init", or "normal gameplay". Level init is the state in which
Zone and Act data are loaded, and the Act Init Function is run.
This state lasts until the Act Init Function is broken or terminated, at which point the game is automatically set to "normal gameplay" mode.
Possible values are:
0 | - | _InLevel_Init | - | Level Init |
1 | - | _InLevel_Gameplay | - | Normal Gameplay |
To restart a level, change this value to 0. To start a different level, change "Zone"
and "Act", and then change "InLevel" to 0. This can be managed all at once by use of the _SetLevel Script Command
8 - _Host_Platform
This value specifies which platform HCGE is running on:
0 | - | _Host_DOS |
1 | - | _Host_Win |
2 | - | _Host_Linx86 |
3 | - | _Host_Macx86 |
4 | - | _Host_MacPPC |
5 | - | _Host_Wii |
6 | - | _Host_PSP |
7 | - | _Host_Wiz |
It is for reference only, changing it manually could cause undesirable effects.
9 - _Curr_Player
This value is the Player (not Character) ID number of the Player that is currently
being processed. It is for reference only, changing it manually could cause undesirable effects.
Advanced - The "Current Player" can be set manually by using one of the
_Set_CurrPlayer_??? Script Commands if a
Script Command that manipulates the "Current Player" must be used outside of normal Player processing. If
this Command is used during normal Player processing for any reason, the original "Current Player" must
be restored after the desired operation is complete
10 - _XMEffectParam
When a "Zxx" effect is encountered during the playing of an XM module, this variable is set equal to the accompanying Effect Parameter ("xx")
This is generally read within a Scripted XM Event Function to determine what event is being called, and how to process it
Manually altering this value has no effect
11 - _Tiles_Length_X
12 - _Tiles_Length_Y
This is the number of tiles that will fit on the screen in it's current size on
the X and Y axes. They are for reference only; changing them manually will cause undesirable
effects
13 - _Screen_Active_Width
14 - _Screen_Active_Height
These are the screen resolution given to objects and players when they need it, which
is not necesarily the current resolution. They are for reference only; changing
them manually will cause undesirable effects
15 - _Screen_Actual_Width
16 - _Screen_Actual_Height
These are the actual size of the current screen resolution. They are for reference only; changing
them manually will cause undesirable effects
17 - _mainvpx
18 - _mainvpy
19 - _vpxr[0]
20 - _vpxr[1]
21 - _vpyr[0]
22 - _vpyr[1]
23 - _LevelBound_X1[0]
24 - _LevelBound_X1[1]
25 - _LevelBound_Y1[0]
26 - _LevelBound_Y1[1]
27 - _LevelBound_X2[0]
28 - _LevelBound_X2[1]
29 - _LevelBound_Y2[0]
30 - _LevelBound_Y2[1]
31 - _Target_LevelBound_X1[0]
32 - _Target_LevelBound_X1[1]
33 - _Target_LevelBound_Y1[0]
34 - _Target_LevelBound_Y1[1]
35 - _Target_LevelBound_X2[0]
36 - _Target_LevelBound_X2[1]
37 - _Target_LevelBound_Y2[0]
38 - _Target_LevelBound_Y2[1]
These values are used to control the "LevelBound" values above. If the values above are not
equal to their counterparts here, they will "scroll" to those targets in steps of 2 if they must cross the
visible screen area or are at the screen's edge. Otherwise, they will instantly be set to these targets
These values may be most easily set by use of the _Player_SetTargetBounds Script Command
39 - _XLoop_Active[0]
40 - _XLoop_Active[1]
41 - _YLoop_Active[0]
42 - _YLoop_Active[1]
These values control whether Level Looping on the X and/or Y axis is active for either screen.
They may be set manually in the following way:
0 | - | _Off | - | The "LevelBound" settings will cause the screen to stop scrolling when those boundaries are reached |
1 | - | _On | - | The "LevelBound" settings will cause the level section within those boundaries to loop |
43 - _BGOffsetX[0]
44 - _BGOffsetX[1]
45 - _BGOffsetY[0]
46 - _BGOffsetY[1]
47 - _XLoop_Size[0]
48 - _XLoop_Size[1]
49 - _YLoop_Size[0]
50 - _YLoop_Size[1]
51 - _Curr_Palette
The ID of the Level Palette that is currently being
used for display. This value is for reference only; changing it manually
will cause undesirable effects. The _Pal_Switch
Script Command can be used to change the Level Palette that will be used for display
.... - (Unused)
Registers 52-53 are currently unused
54 - _Water_Level
55 - _FrameCounter
This value automatically increases by 1 for every Game Frame that is processed. It can be read or set for any reason at any time
56 - _VPX_Bounce[0]
57 - _VPX_Bounce[1]
58 - _VPY_Bounce[0]
59 - _VPY_Bounce[1]
When these values are set, they offset the viewport of their corresponding screen on the X or Y axis by the given pixel amount, and are automatically modified in such a way that the screen appears to "shake".
Given a setting of 4, for example, the pattern would be: 4, -4, 3, -3, 2, -2, 1, -1, 0
.... - (Unused)
Registers 60-199 are currently unused
.... - (Reserved)
.... - (Unused)
Registers 232-240 are currently unused
241 - _OE_Property[0]
242 - _OE_Property[1]
243 - _OE_Property[2]
244 - _OE_Property[3]
These variables correspond with the four available "Object Property" settings within the Object Editor.
They may be used within Scripted "Debug Drawing" and "Debug Placement" Functions to control how the Object is represented and placed from within the Object Editor or Debug Mode
Maximum and minimum values must be enforced within the Scripted Debug Drawing Function, as the Object Editor can not know which values are invalid for each Object, and will otherwise allow these variables to be set to any value from -2147483648 to 2147483647
These values may also be manipulated by other Functions for the purpose of altering drawing and placement behavior for Debug Mode
245 - _Key_InitialDelay
This value specifies the number of Game Frames for which a key's "Repeat" state should remain false after first being pressed.
Once this delay has expired, the "Repeat" state will become true for exactly one frame before "Key_RepeatDelay" takes effect
246 - _Key_RepeatDelay
This value specifies the number of Game Frames that should pass between each frame that a key's "Repeat" state becomes true.
Once a key has been pressed, and "Key_InitialDelay" expires, the "Repeat" state becomes true for exactly one frame, and then becomes false again for the number of frames specified by this value.
The "Repeat" state then becomes true again for exactly one frame before this same delay is repeated, and this process continues until the key is released
247 - _VSync
This value specifies whether or not "VSync" (reduces "tearing", but can be slower) is used. Possible values are:
0 - VSync is not enabled
1 - VSync is enabled only in full-screen mode (default)
2 - VSync is enabled only in windowed mode
3 - VSync is enabled in all modes
248 - _GameFlags
Contains miscellaneous Flags:
0 - FPS Display Toggle- 0 for off, 1 for on
1 - The type of song that is (or is about to be) playing- 0 for Wav, 1 for XM
249 - _FrameSkipCount
When "Frame Skipping" is enabled ("FrameSkip" is nonzero), this is the counter. The counter counts up to the
value of "FrameSkip" and then resets, and the screen is only drawn each time the counter value is 0
250 - _FrameSkip
This value specifies the number of Frames that will be skipped (the game will run this many Game Frames before
the screen is drawn). If this value is 0, the screen is updated for every Game Frame
251 - _FrameLock
This value determines whether or not the game's frame rate will be locked to 60 Game Frames per second. Possible values are:
0 - The game will update based on a timer that only allows for a maximum of 60 Game Frames per second
1 - The game will process as many Game Frames per second as the host system can handle (this rate will be erratic, as each Game Frame will take a different amount of time to process depending on what needs to be done)
252 - _piccount
This is the ID that will be assigned to the next screen-shot
253 - _GamePaused
If this value is "1", the game will be in "Paused" mode. Scripts, as well as
everything else, will be stopped in this mode, so setting this value manually will freeze the game
permanently. To put the game into a controllable "Paused" mode, one of the
_PauseGame_??? Script Commands
may be used to assign a Game Function or Status Script Object to run during the "Pause". This will be
the only Function or Object that will be active during the "Pause", and is the only way that the "Pause"
can be disabled
If this value is greater than 1, this Register acts as a counter, and that number of Game Frames will
be processed before the game enters "Paused" state. This can be managed by a Function or Status Script Object
assigned to run during the pause
If this value is 0, the game will run normally
254 - _Max_Objects_Used
This value represents the number of Game Objects that are currently active.
This value is for reference only; changing it manually will cause undesirable effects
255 - (Reserved)